#![allow(dead_code)]

pub fn insert_values() -> Vec<usize> {
    // insert M ge N, N from 1 -> infinity.
    // M is 1 num when N to binary
    // query index in List, output values

    // find when in i, what's the value it is

    fn get_ones_num_as_binary(mut i: usize) -> usize {
        let mut count = 0;
        while i != 0 {
            count += i & 1;
            i >>= 1;
        }
        count
    }

    println!("{}", get_ones_num_as_binary(4));
    println!("{}", get_ones_num_as_binary(6));
    println!("{}", get_ones_num_as_binary(5));
    println!("{}", get_ones_num_as_binary(10));

    let indexes = vec![4, 5, 6];

    let mut ans = Vec::new();

    // to get value of i, for 1,i, get the final sum result
    for v in indexes {
        let mut list_tmp = Vec::new();
        let mut i: usize = 0;
        while list_tmp.len() <= v {
            // let one_num = get_ones_num_as_binary(i);
            let one_num = i.count_ones();
            for n in 0..one_num {
                list_tmp.push(i);
            }

            i += 1;
        }
        // list_tmp
        println!("{} {:?}", v, list_tmp);
        ans.push(list_tmp[v]);
    }

    println!("{:?}", ans);
    //
    ans
}
